package com.qdu.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/*
 * 生成随机的UUID防止id重复
 * 具体数据形式为: 年份后两位+月+日+时+分+秒+两位随机生成数
 */
public class GenerateUUID {
    public static String generateUUID(){
        String uuid = "";
        Random rand = new Random();
        int random = rand.nextInt(100);
        String x = String.format("%02d", random);

        Date date = new Date();
        SimpleDateFormat df = new SimpleDateFormat("yyMMddHHmmss");
        String d = df.format(date);
        uuid = d + x;
        return uuid;
    }

}

